﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using XDL.Framework.Messaging;
using XDL.Framework.Particles;
using XDL.Framework;
using JumpNFight.Weapons;

namespace JumpNFight.Simulation
{
    abstract class NPCBase :
       EntityBase
    {
        Sliceable m_sliceable;
        public abstract int NPCType
        {
            get;
        }

        public override Sliceable Sliceable
        {
            get
            {
                return m_sliceable;
            }
        }

        public NPCBase(int id, Game game):
            base(id,game)
        {
            m_sliceable = new Sliceable(this);
        }

        public override bool ProcessEvent(GameTime gameTime, int msgId, EventArgs e)
        {
            switch (msgId)
            {
                case EntityBase.HitEvent:
                    {
                        WeaponHitEventArgs hitArgs = (WeaponHitEventArgs)e;
                        LastHitTime = gameTime.TotalGameTime;
                        Health -= hitArgs.Weapon.Damage;
                        IsFireDamage = hitArgs.IsFireDamage;
                        if (Health <= 0)
                        {
                            // 
                            GameServices.EventDispatcher.PostEvent(hitArgs.OwnerID, Player.RegisterKillEvent, null);
                            Kill(gameTime, hitArgs.Velocity);
                        }
                    }
                    break;

                default:
                    return base.ProcessEvent(gameTime, msgId, e);
            }

            return true;
        }
    }
}
